#include <signal.h>


sighandler_t signal(int signum, sighandler_t handler);
/*
 * RETURN VALUE
 *      signal() returns the previous value of the signal handler,
 *      or SIG_ERR on error. In the event of an error, errno is set
 *      to indicate the cause
 * ERRORS
 *      EINVAL  signum is invalid
 */




#include <sys/types.h>
#include <signal.h>

int kill(pid_t pid, int sig);
/*
 * RETURN VALUE
 *      On success (at least one signal was sent), zero is returned.
 *      On error, -1 is returned, and errno is set appropriately.
 * ERRORS
 *      EINVAL  An invalid signal was specified.
 *      EPERM   The process does not have permission to send the signal
 *              to any of the target processes.
 *      ESRCH   The pid or process group does not exits. Note that an
 *              existing process might be a zombie, a process which
 *              already commited termination, but has not yet been
 *              waited for.
 */

int raise(int sig);
/*
 * RETURN VALUE
 *      raise() returns 0 on success, and nonzero for failure.
 */




#include <unistd.h>

unsigned int alarm(unsigned int seconds);
/*
 * RETURN VALUE
 *      alarm() returns the number of seconds remaining until any previously
 *      scheduled alarm was due to be delivered, or zero if there was no
 *      previously scheduled alram.
 */

int pause(void);
/*
 * RETURN VALUE
 *      pause() returns only when a signal was caught and the signal-catching
 *      function returned. In this case pause() return -1, and errno is set
 *      to EINTR.
 * ERRORS
 *      EINTR   a signal was caught and the signal-catching function returned.
 */




#include <signal.h>

int sigemptyset(sigset_t *set);

int sigfillset(sigset_t *set);

int sigaddset(sigset_t *set, int signum);

int sigdelset(sigset_t *set, int signum);

int sigismember(const sigset_t *set, int signum);

/*
 * RETURN VALUE
 *      sigemptyset(), sigfillset(), sigaddset(), and sigdelset() return 0
 *      on success and -1 on error.
 *
 *      sigismember() returns 1 if signum is a mumber of set, 0 if signum
 *      is not a member, and -1 on error. On error, these functions set
 *      errno to indicate the cause.
 * ERRORS
 *      EINVAL  sig is not a valid signal.
 */

/*
 * A SIMPLE IMPLEMENTATION OF sigemptyset & sigfillset
 */
#define sigemptyset(ptr)    (*(ptr) = 0)
#define sigfillset(ptr)     (*(ptr) = ~(sigset_t)0, 0)




#include <signal.h>

int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);

/*
 * RETURN VALUE
 *      sigprocmask() return 0 on success and -1 on error. In the event
 *      of an error, errno is set to indicate the cause.
 * ERRORS
 *      EFAULT  the set or oldset argument points outside the process's
 *              allocated address space.
 *      EINVAL  the value specified in how was invalid.
 */




#include <signal.h>

int sigpending(sigset_t *set);

/*
 * RETURN VALUE
 *      sigpending() returns 0 on success and -1 on error. In the event of
 *      an error, errno is set to indicate the cause.
 * ERRORS
 *      EFAULT  set points to memory which is not a valid part of the
 *              process address space.
 */




#include <signal.h>

int sigaction(int signum, const struct sigaction *act,
              struct sigaction *oldact);

/*
 * The sigaction structure is defined as something like:
 *
 *      struct sigaction {
 *          void    (*sa_handler)(int);
 *          void    (*sa_sigaction)(int, siginfo_t *, void *);
 *          sigset_t    sa_mask;
 *          int         sa_flags;
 *          void    (*sa_restorer)(void);
 *      };
 *
 *  The sa_restorer element is obsolete and should not be used. POSIX does
 *  not specify a sa_restorer element.
 *
 * RETURN VALUE
 *      sigaction() return 0 on success; on error, -1 is returned, and errno
 *      is set to indicate the error.
 *
 * ERRORS
 *      EFAULT  act or oldact points to memory which is not a valid part of
 *              the process address space.
 *      EINVAL  An invalid signal was specified. This will also be generated
 *              if an attempt is made to change the action for SIGKILL or
 *              SIGSTOP, which cannot be caught or ignored.
 */




#include <setjmp.h>

int setjmp(jmp_buf env);
int sigsetjmp(sigjmp_buf env, int savesigs);

/*
 * RETURN VALUE
 *      setjmp() and sigsetjmp() return 0 if returning directly, and nonzero
 *      when returning from longjmp or siglongjmp using the saved context.
 */

void longjmp(jmp_buf env, int val);
void siglongjmp(sigjmp_buf env, int val);

/*
 * RETURN VALUE
 *      These function never reurn.
 */




#include <signal.h>

int sigsuspend(const sigset_t *mask);

/*
 * RETURN VALUE
 *      sigsuspend() always return -1, with errno set to indicate the error 
 *      (normally, EINTR).
 *
 * ERRORS
 *      EFAULT  mask points to memory which is not a valid part of the process
 *              address space.
 *      EINTR   The call was interrupted by a signal.
 */




#include <stdlib.h>

void abort(void);

/*
 * RETURN VALUE
 *      The abort() function never returns.
 */




#include <stdlib.h>

int system(const char *command);

/* RETURN VALUE
 *      The value returned is -1 on error (e.g., fork failed), and the return
 *      status of the command otherwise. This latter return status is in the
 *      format specified in wait. Thus, the exit code of the command will be
 *      WEXITSTATUS(status). In case /bin/sh could not be executed, the exit
 *      status will be that of a command that does exit(127).
 *
 *      If the value of command is NULL, system() returns nonzero if the 
 *      shell is available, and zero if not.
 *
 *      system() does not affect the wait status of any other children.
 */




#include <unistd.h>

unsigned int sleep(unsigned int seconds);

/*
 * RETURN VALUE
 *      Zero if the requested time has elapsed, or the number of seconds left
 *      to sleep, if the call was interrupted by a signal handler.
 */




#include <time.h>
int nanosleep(const struct timespec *req, struct timespec *rem);

/*
 * The structure timespec is used to specify intervals of time with nanosecond
 * precision. It is defined as follows:
 *
 *      struct timespec {
 *          time_t  tv_sec;         // seconds
 *          long    tv_nsec;        // nanoseconds
 *      }
 *
 * RETURN VALUE
 *      On successfully sleeping for the requested interval, nonosleep()
 *      returns 0. If the call is interrupted by a signal handler or
 *      encounters an error, then it returns -1, with errno set to indicate
 *      the error.
 *
 * ERROR
 *      EFAULT  Problem with copying information from user space.
 *      EINTR   The pause has been interrupted by a signal that was delivered
 *              to the thread. The remaining sleep time has been written
 *              into *rem so that the thread can easily call nanosleep() again
 *              and continue with the pause.
 *      EINVAL  The value in the tv_nsec field was not in the range 0 to
 *              999999999 or tv_sec was negative.
 */




#include <time.h>

int clock_nanosleep(clockid_t clock_id, int flags,
                    const struct timespec *request,
                    struct timespec *remain);

/*
 * The clock_id argument specifieds the clock against which the sleep interval
 * is to be measured. This argument can have one of the following values:
 *      CLOCK_REALTIME      A settalbe system-wide real-time clock.
 *      CLOCK_MONOTONIC     A nonsettable, monotonically increasing clock that
 *                          measures time since some unspecified point in the
 *                          past that does not change after system startup.
 *      CLOCK_PROCESS_CPUTIME_ID
 *                          A settable per-process clock that measures CPU time
 *                          consumed by all threads in the process.
 *
 * RETURN VALUE
 *      On successfully sleeping for the requested interval, clock_nanosleep()
 *      returns 0. If the call is interrupted by a signal handler or
 *      encounters an error, then it returns one of the positive error number
 *      listed in ERRORS.
 *
 * ERRORS
 *      EFAULT  request or remain specified an invalid address.
 *      EINTR   The sleep was interrupted by a signal handler.
 *      EINVAL  The value in the tv_nsec field was not in the range 0 to
 *              999999999 or tv_sec was negative.
 *      EINVAL  clock_id was invalid. (CLOCK_THREAD_CPUTIME_ID is not a
 *              permitted value for clock_id.)
 */




#include <signal.h>

int sigqueue(pid_t pid, int sig, const union sigval value);

/*
 * RETURN VALUE
 *      On success, sigqueue() returns 0, indicating that the signal was
 *      successfully queued to the receiving process. Otherwise -1 is
 *      returned and errno is set to indicate the error.
 *
 * ERRORS
 *      EAGAIN  The limit of signals which may be queued has been reached.
 *      EINVAL  sig was invalid.
 *      EPERM   The process does not have permission to send the signal to
 *              the receiving process.
 *      ESRCH   No process has a PID matching pid.
 */




#include <signal.h>

void psignal(int sig, const char *s);
void psiginfo(const siginfo_t *pinfo, const char *s);

extern const char *const sys_siglist[];

/*
 * RETURN VALUE
 *      The psignal() and psiginfo() functions return no value.
 */




#include <string.h>

char *strsignal(int sig);

extern const char * const sys_siglist[];

/*
 * RETURN VALUE
 *      The strsignal() function returns the appropriate description string,
 *      or an unknown signal message if the signal number is invalid. On some
 *      systems (but not on Linux), a NULL pointer may be returned instead
 *      for an invalid signal number.
 */
